package com.chrray.position.service.web.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chrray.position.domain.FdHomeAd;
import com.chrray.position.domain.dto.FdHomeAdDTO;
import com.chrray.position.domain.dto.search.FdHomeAdSearch;
import com.chrray.position.domain.vo.FdHomeAdVO;
import com.chrray.position.exception.ServiceException;
import com.chrray.position.mapper.position.FdHomeAdMapper;
import com.chrray.position.pojo.dto.web.FdHomeAdExe;
import com.chrray.position.service.position.FdHomeAdService;
import com.chrray.position.service.web.WFdHomeAdService;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 首页广告配置表 接口实现类
 *
 * @author wusiwee
 * @email wusiwee@163.com
 * @since 1.0.1 2024-08-07
 */
@Service
@AllArgsConstructor
public class WFdHomeAdServiceImpl extends ServiceImpl<FdHomeAdMapper, FdHomeAd> implements WFdHomeAdService {


    @Override
    public IPage pageList(FdHomeAdExe entity) {
        LambdaQueryWrapper<FdHomeAd> queryWrapper = new LambdaQueryWrapper<>();

        queryWrapper.eq(!ObjectUtils.isEmpty(entity.getName()), FdHomeAd::getName, entity.getName());
        queryWrapper.orderByDesc(FdHomeAd::getStatus);
        IPage page = entity.getPage();
        IPage<FdHomeAd> pageList = this.page(page, queryWrapper);
        return  pageList;
    }
}
